package com.newcapec.modules.pass.controller;

import com.newcapec.common.utils.PageUtils;
import com.newcapec.common.utils.R;
import com.newcapec.modules.pass.entity.PassRecordEntity;
import com.newcapec.modules.pass.service.PassRecordService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * 出入记录
 *
 * @author steven
 * @email wangsen127@163.com
 * @date 2021-12-29 12:54:36
 */
@RestController
@RequestMapping("pass/passrecord")
public class PassRecordController {
    @Autowired
    private PassRecordService passRecordService;

    /**
     * 列表
     */
    @GetMapping("/list")
    @RequiresPermissions("pass:passrecord:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = passRecordService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 信息：废弃
     */
    @Deprecated
    @GetMapping("/info/{id}")
    @RequiresPermissions("pass:passrecord:info")
    public R info(@PathVariable("id") Integer id){
		PassRecordEntity passRecord = passRecordService.getById(id);

        return R.ok().put("passRecord", passRecord);
    }

    /**
     * 保存：废弃
     */
    @Deprecated
    @PostMapping("/save")
    @RequiresPermissions("pass:passrecord:save")
    public R save(@RequestBody PassRecordEntity passRecord){
		passRecordService.save(passRecord);

        return R.ok();
    }

    /**
     * 修改：废弃
     */
    @Deprecated
    @PutMapping("/update")
    @RequiresPermissions("pass:passrecord:update")
    public R update(@RequestBody PassRecordEntity passRecord){
		passRecordService.updateById(passRecord);

        return R.ok();
    }

    /**
     * 删除：废弃
     */
    @Deprecated
    @DeleteMapping("/delete")
    @RequiresPermissions("pass:passrecord:delete")
    public R delete(Integer[] ids){
		passRecordService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }
}
